﻿using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;

namespace Reborn.Infrastructure
{
    public class ServiceCollectionProvider
    {
        ServiceCollection _services = new ServiceCollection();

        ServiceProvider _serviceProvider = null;

        private static ServiceCollectionProvider instance = null;
        public static ServiceCollectionProvider Instance
        {
            get
            {
                if (instance == null)
                {
                    lock (Locker.Unique)
                    {

                        if (instance == null) instance = new ServiceCollectionProvider();
                    }
                }
                return instance;
            }
        }

        public ServiceCollectionProvider() { 
        
        }

        public ServiceCollection Service
        {
            get
            {
                return _services;
            }
        }

        public ServiceProvider Provider
        {
            get
            {
                return _serviceProvider;
            }
        }

        public void Build()
        {
            _serviceProvider = _services.BuildServiceProvider();
        }
    }
}
